import * as actionTypes from './actionTypes';
import * as Status from './status';

export default function reducer(state = {}, action) {
	switch(action.type) {
		case actionTypes.FETCH_STARTED:
			return Object.assign({}, state, {status: Status.LOADING});
		case actionTypes.FETCH_SUCCESS:
			return Object.assign({}, state, {
				status: Status.SUCCESS,
				...action.result
			});
		case actionTypes.FETCH_FAILURE:
			return Object.assign({}, state, {status: Status.FAILURE});
		default:
			return state;
	}
}
			